Scripting > CxCas > CasClient Object > CasClient Methods

CasClient Methods

The CasClient object contains the following methods:

AcknowledgeAlarm

The AcknowledgeAlarm method acknowledges the alarm associated with a specified point tag.

Syntax

AcknowledgeAlarm(Tag As String, AlarmRecVersion As String, Comment As String)

Parameters

Parameter Required Description

Tag

Yes

The tag for the point with an alarm to be acknowledged. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

AlarmRecVersion

Yes

The current alarm record version for the tag in the CAS.

Comment

Yes

The comment to apply.  This parameter can be an empty string.

Remarks

This method has no return value, and will fail if an error occurs.

Example

The following example checks if user 'joe.bob' can acknowledge the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, acknowledges the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserAcknowledgeAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.AcknowledgeAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm acknowledged"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

CanUserAcknowledgeAlarm

The CanUserAcknowledgeAlarm method returns true if the specified user has the appropriate security privilege to acknowledge alarms for a specified point.

Syntax

CanUserAcknowledgeAlarm(Tag As String, UserName As String) As Boolean

Parameters

Parameter Required Description

Tag

Yes

The tag for the point to be checked for security privilege. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

UserName

Yes

The ID of the user to be checked for security privilege.

Example

The following example checks if user 'joe.bob' can acknowledge the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, acknowledges the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserAcknowledgeAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.AcknowledgeAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm acknowledged"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

CanUserClearAlarm

The CanUserClearAlarm method returns true if the specified user has the appropriate security privilege to clear alarms for a specified point.

Syntax

CanUserClearAlarm(Tag As String, UserName As String) As Boolean

Parameters

Parameter Required Description

Tag

Yes

The tag for the point to be checked for security privilege. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

UserName

Yes

The ID of the user to be checked for security privilege.

Example

The following example checks if user 'joe.bob' can clear the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, clears the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserClearAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.ClearAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm cleared"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

CanUserDoAlarmAction

The CanUserDoAlarmAction method returns true if the specified user has the appropriate security privilege to do the specified alarm action for a specified point.

Syntax

CanUserDoAlarmAction(Action As String, Tag As String, UserName As String) As Boolean

Parameters

Parameter Required Description

Action

Yes

The alarm action to be checked for security privilege.  This parameter can be one of the following values:

  • "ACK" — Acknowledge alarm
  • "HIDE" — Hide alarm
  • "UNHIDE" — Unhide alarm
  • "CLEAR" — Clear alarm
  • "FORCE" — Force clear alarm.

Tag

Yes

The tag for the point to be checked for security privilege. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

UserName

Yes

The ID of the user to be checked for security privilege.

Example

The following example checks if user 'joe.bob' can acknowledge the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, acknowledges the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserDoAlarmAction("ACK", "CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.DoAlarmAction "ACK", "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm acknowledged"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

CanUserForceClearAlarm

The CanUserForceClearAlarm method returns true if the specified user has the appropriate security privilege to force clear alarms for a specified point.

Syntax

CanUserForceClearAlarm(Tag As String, UserName As String) As Boolean

Parameters

Parameter Required Description

Tag

Yes

The tag for the point to be checked for security privilege. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

UserName

Yes

The ID of the user to be checked for security privilege.

Example

The following example checks if user 'joe.bob' can force clear the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, force clears the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserForceClearAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.ForceClearAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm cleared"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

CanUserHideAlarm

The CanUserHideAlarm method returns true if the specified user has the appropriate security privilege to hide alarms for a specified point.

Syntax

CanUserHideAlarm(Tag As String, UserName As String) As Boolean

Parameters

Parameter Required Description

Tag

Yes

The tag for the point to be checked for security privilege. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

UserName

Yes

The ID of the user to be checked for security privilege.

Example

The following example checks if user 'joe.bob' can hide the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, hides the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserHideAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.HideAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm hidden"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

CanUserUnhideAlarm

The CanUserUnhideAlarm method returns true if the specified user has the appropriate security privilege to unhide alarms for a specified point.

Syntax

CanUserUnhideAlarm(Tag As String, UserName As String) As Boolean

Parameters

Parameter Required Description

Tag

Yes

The tag for the point to be checked for security privilege. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

UserName

Yes

The ID of the user to be checked for security privilege.

Example

The following example checks if user 'joe.bob' can unhide the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, unhides the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserUnhideAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.UnhideAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm unhidden"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

ClearAlarm

The ClearAlarm method clears the alarm associated with a specified point tag.

Syntax

ClearAlarm(Tag As String, AlarmRecVersion As String, Comment As String)

Parameters

Parameter Required Description

Tag

Yes

The tag for the point with an alarm to be cleared. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

AlarmRecVersion

Yes

The current alarm record version for the tag in the CAS.

Comment

Yes

The comment to apply.  This parameter can be an empty string.

Remarks

This method has no return value, and will fail if an error occurs.

Example

The following example checks if user 'joe.bob' can clear the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, clear the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserClearAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.ClearAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm cleared"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

Connect

The Connect method connects the object to a service.

Syntax

Connect(DomainSiteService As String)

Parameters

Parameter Required Description

DomainSiteService

Yes

The [Domain]Site.Service to which to connect.  A domain is optional. The service must be a valid CAS.

Remarks

Returns 0 if successful and a non-zero value if the connection failed.

Example

The following example connects the CasClient object to the CYGDEMO.CAS on domain 5410:

Sub CasConnect()

'Connect to a CAS

Dim CasClient

Set CasClient = CreateObject("CxCas.CasClient")

CasClient.Connect("[5410]CYGDEMO.CAS")

End Sub

Back to top

Disconnect

The Disconnect method disconnects from the service.

Syntax

Disconnect()

Example

The following example disconnects the CasClient object from the CAS service:

Sub

  CasClient.Disconnect

 

End Sub

Back to top

DoAlarmAction

The DoAlarmAction method performs the specified action for the alarm associated with the specified point tag.

Syntax

DoAlarmAction(Action As String, Tag As String, AlarmRecVersion As String, Comment As String)

Parameters

Parameter Required Description

Action

Yes

The alarm action to be checked for security privilege.  This parameter can be one of the following values:

  • "ACK" — Acknowledge alarm
  • "HIDE" — Hide alarm
  • "UNHIDE" — Unhide alarm
  • "CLEAR" — Clear alarm
  • "FORCE" — Force clear alarm.

Tag

Yes

The tag for the point with an alarm to be acted upon. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

AlarmRecVersion

Yes

The current alarm record version for the tag in the CAS.

Comment

Yes

The comment to apply.  This parameter can be an empty string.

Remarks

This method has no return value, and will fail if an error occurs.

Example

The following example checks if user 'joe.bob' can acknowledge the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, acknowledges the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserDoAlarmAction("ACK", "CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.DoAlarmAction "ACK", "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm acknowledged"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

ForceClearAlarm

The ForceClearAlarm method force clears the alarm associated with a specified point tag.

Syntax

ForceClearAlarm(Tag As String, AlarmRecVersion As String, Comment As String)

Parameters

Parameter Required Description

Tag

Yes

The tag for the point with an alarm to be cleared. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

AlarmRecVersion

Yes

The current alarm record version for the tag in the CAS.

Comment

Yes

The comment to apply.  This parameter can be an empty string.

Remarks

This method has no return value, and will fail if an error occurs.

Example

The following example checks if user 'joe.bob' can force clear the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, force clears the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserForceClearAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.ForceClearAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm cleared"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

GetAlarmRecordId

The GetAlarmRecordId method returns the short tag, alarm record version, and value timestamp for the given point tag. If the point tag is not known to the CAS service, an empty string will be returned for the short tag.

Syntax

GetAlarmRecordId(ByVal Tag As String)

Parameters

Parameter Required Description

Tag

Yes

The tag for the point with an alarm to be retrieved. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

Back to top

GetAlarmRecordIds

The GetAlarmRecordId method returns the short tags, alarm record versions, and value timestamps for all points in alarm.

Syntax

GetAlarmRecordIds

Back to top

GetConsoleData

The GetConsoleData method returns the console text and display attributes as two 25x80 arrays of unsigned characters.

Syntax

GetConsoleData(ByRef pText, ByRef pAttr) As Integer

Parameters

Parameter Required Description

pText

Yes

A two-dimensional 25x80 array of console text attributes returned by this method.

pAttr

Yes

A two-dimensional 25x80 array of console display attributes returned by this method.

Remarks

This method returns 0 if successful.

Example

The following example writes the console text and display attributes to a CSV file.

Sub

Dim aryText, aryAttr, nRet

nRet = CasClient.GetConsoleData(aryText, aryAttr)

 

' Write text attributes to CSV file

Dim i, j, strMsg

For i = 0 To UBound(aryText, 1)

For j = 0 To UBound(aryText, 2)

strMsg = strMsg + CStr(aryText(i, j)) + ","

Next

strMsg = strMsg + vbCr

Next

 

dim fso, file

Set fso = CreateObject("Scripting.FileSystemObject")

Set file = fso.OpenTextFile("c:\console_text_attrs.csv", 2, True)

file.WriteLine(strMsg)

file.Close

 

strMsg = ""

 

' Write display attributes to CSV file

For i = 0 To UBound(aryAttr, 1)

For j = 0 To UBound(aryAttr, 2)

strMsg = strMsg + CStr(aryAttr(i, j)) + ","

Next

strMsg = strMsg + vbCr

Next

 

Set file = fso.OpenTextFile("c:\console_disp_attrs.csv", 2, True)

file.WriteLine(strMsg)

file.Close

 

MsgBox nRet

End Sub

Back to top

GetReferences

The GetReferences method refreshes the list of services referenced by the connected service.

Syntax

GetReferences()

Example

The following example refreshes the connected services:

Sub

 

CasClient.GetReferences

 

End Sub

Back to top

HideAlarm

The HideAlarm method hides the alarm associated with a specified point tag.

Syntax

HideAlarm(Tag As String, AlarmRecVersion As String, Comment As String)

Parameters

Parameter Required Description

Tag

Yes

The tag for the point with an alarm to be hidden. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

AlarmRecVersion

Yes

The current alarm record version for the tag in the CAS.

Comment

Yes

The comment to apply.  This parameter can be an empty string.

Remarks

This method has no return value, and will fail if an error occurs.

Example

The following example checks if user 'joe.bob' can hide the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, hides the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserHideAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.HideAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm hidden"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

UnhideAlarm

The UnhideAlarm method unhides the alarm associated with a specified point tag.

Syntax

UnhideAlarm(Tag As String, AlarmRecVersion As String, Comment As String)

Parameters

Parameter Required Description

Tag

Yes

The tag for the point with an alarm to be unhidden. It can be in Site.Service.PointId or Site.Service.PointId:LongId form.

AlarmRecVersion

Yes

The current alarm record version for the tag in the CAS.

Comment

Yes

The comment to apply.  This parameter can be an empty string.

Remarks

This method has no return value, and will fail if an error occurs.

Example

The following example checks if user 'joe.bob' can unhide the alarm for point 'CYGDEMO.UIS.00001099:MY_LONGPOINTID', and, if so, unhides the alarm. To return the alarm acknowledge state, append the ;ack parameter when adding the point. See CxScript Point Properties for more information.

Sub

 

Dim bRet

bRet = CasClient.CanUserUnhideAlarm("CYGDEMO.UIS.00001099", "joe.bob")

 

Dim Points

Set Points = CreateObject("CxScript.Points")

Points.AddPoint("CYGDEMO.UIS:MY_LONGPOINTID;ack")

Points.UpdateNow 0

 

Dim Point

Set Point = Points.Point("CYGDEMO.UIS:MY_LONGPOINTID")

 

Dim AlarmRecVersion

AlarmRecVersion = Point.GetAttribute("alarmrecversion")

 

If (bRet) Then

CasClient.UnhideAlarm "CYGDEMO.UIS.00001099", AlarmRecVersion, "Alarm unhidden"

Else

MsgBox "User does not have the appropriate security privilege"

End If

 

End Sub

Back to top

Let us know how we can improve this topic.

CygNet at weatherford.com

© 2020 Weatherford. All rights reserved.